#include <iostream>
#include <fstream>
#include <ctime>
using namespace std;

int main()
{
    const int LEN = 5000;
    int a1[LEN], a2[LEN], a3[LEN], i;
   
    ifstream fin("m1_sorted.txt");
    for(int i=0; i < LEN; i++) fin >> a1[i];
    fin.close();
    ifstream fin1("m2_reverse.txt");
    for(int i=0; i < LEN; i++) fin >> a2[i];
    fin1.close();
    ifstream fin2("m3_shuffle.txt");
    for(int i=0; i < LEN; i++) fin >> a3[i];
    fin2.close();
    i = 0;
    bool f = true;
    unsigned int t_start = clock();
    while(f){
        f = false;
        for(int ii = 0; ii < LEN - i - 1; ii++){
            if(a1[ii] > a1[ii + 1]){
                int d = a1[ii];
                a1[ii] = a1[ii + 1];
                a1[ii + 1] = d;
                f = true;
            }
        }
        i++;
    }
    unsigned int t_finish = clock();
    unsigned int t_work = t_finish - t_start;
    cout<<"m1_sorted " << t_work << " milliseconds \n";
   
    i = 0;
    f = true;
    t_start = clock();
    while(f){
        f = false;
        for(int ii = 0; ii < LEN - i - 1; ii++){
            if(a2[ii] > a2[ii + 1]){
                int d = a2[ii];
                a2[ii] = a2[ii + 1];
                a2[ii + 1] = d;
                f = true;
            }
        }
        i++;
    }
    t_finish = clock();
    t_work = t_finish - t_start;
    cout<<"m2_reverse.txt " << t_work << " milliseconds \n";
   
   
    i = 0;
    f = true;
    t_start = clock();
    while(f){
        f = false;
        for(int ii = 0; ii < LEN - i - 1; ii++){
            if(a3[ii] > a3[ii + 1]){
                int d = a3[ii];
                a3[ii] = a3[ii + 1];
                a3[ii + 1] = d;
                f = true;
            }
        }
        i++;
    }
    t_finish = clock();
    t_work = t_finish - t_start;
    cout<<"m3_shuffle.txt " << t_work << " milliseconds \n";
    return 0;
}